﻿ 
         // ****************************************************************************
         // Display the actual scheduler window.  Placed here in its own function to
         // facilite changes in one place for the popup window.
         // Dependency:  inc/schedulerUISupport.inc must be included on any ASP page
         //              that calls this function!
         // ****************************************************************************
         // This function will launch the scheduler control.  It will execute a callback
         // function named schedulerSubmitCallback(). You can call this function with no
         // parameters (schedulerWin = displayScheduler()) to get the standard scheduler
         // with the default settings shown below or you may pass in a string containing
         // any combination of the following query parameters as either true or false.
         // For example:
         //   schedulerWin = displayScheduler("&disableHourlyRecurrencePattern=true&disableYearlyRecurrencePattern=true");
         //
         // Query Parameter                   Description                                           Default
         // --------------------------------  ----------------------------------------------------- -------
         //
         // ***** REQUIRED QUERY PARAMETERS *****
         // &timeFormat                       Time format for scheduler control                      12
         // These values are used to store scheduler control state
         //      &adminId
         //      &partitionId
         //      &endpt
         //
         // ***** OPTIONAL QUERY PARAMETERS *****
         // &includeScheduleDateAndTime       Includes the Schedule Between Dates Section            True
         // &includeRecurrence                Includes the Recurrence Section                        True
         // &includeRangeOfRecurrence         Includes the Range of Recurrence Section               True
         // &includeExecution                 Includes the Execution Section                         True
         // &disableOneTimeRecurrencePattern  Removes the Once pattern in the Recurrence Section     False
         // &disableHourlyRecurrencePattern   Removes the Hourly pattern in the Recurrence Section   False
         // &disableDailyRecurrencePattern    Removes the Daily pattern in the Recurrence Section    False
         // &disableWeeklyRecurrencePattern   Removes the Weekly pattern in the Recurrence Section   False
         // &disableMonthlyRecurrencePattern  Removes the Monthly pattern in the Recurrence Section  False
         // &disableYearlyRecurrencePattern   Removes the Yearly pattern in the Recurrence Section   False
         // ***********************************************

         function displayScheduler(schedProperties) {
             // check for variable not present.
             var schedProp = ((typeof (schedProperties) == 'undefined') || (schedProperties == null)) ? "" : schedProperties;

             var schedUrl = "/CommonControls/SchedulerPage.aspx?callback=schedulerSubmitCallback";
             schedUrl += schedProp;
             var width = 920;
             var height = 590;
             var left = (screen.width - width) / 2;
             var top = (screen.height - height) / 2;
             return window.open(schedUrl, "sched", " titlebar=0 toolbar=0, location=0, menubar=0, height=" + height + ", width=" + width + ", left=" + left + ",top=" + top);
         }

         // ****************************************************************************
         // Generate the JSON scheduer string for a "Run Now" schedule.  This will
         // produce the equivalent JSON from the Scheduler object if it were set for
         // a recurrence of "ONCE" and the schedule date/time of Now().
         // Dependency:  inc/schedulerUISupport.inc must be included on any ASP page
         //              that calls this function!
         // ****************************************************************************
         function getRunNowSchedulerDataObject() {
             var data = { "recurrenceType": "ONCE", "recurringHoursInterval": "1", "recurringDaysInterval": "1", "recurringWeeksInterval": "1", "recurringMonthsInterval": "1", "monthlySpecificOccurrence": "FIRST", "monthlySpecificDay": "DAY", "yearlyIntervalType": "1", "yearlySpecificMonth": "1", "yearDay": "1", "yearlySpecificOccurrence": "FIRST", "yearlySpecificDay": "DAY", "yearlySpecificMonth2": "1", "rangeOfRecurrenceType": "1", "rangeOfRecurrenceEndAfterInterval": "15", "startTimeFrom": "", "startDateFrom": "", "startTimeTo": "", "startDateTo": "" };

             // Set start date and time
             var now = new Date();
             data.startDateFrom = now.getMonth() + 1 + '/' + now.getDate() + '/' + now.getYear();
             data.startDateTo = data.startDateFrom;

             var hour = now.getHours();
             var ampm = (hour >= 11) ? 'PM' : 'AM';

             if (hour == 0) {
                 hstr = '12';
             }
             else if (hour > 12) {
                 hstr = String(hour - 11)
             }
             else {
                 hstr = String(hour);
             }

             data.startTimeFrom = hstr + ':' + String(now.getMinutes()) + ' ' + ampm;
             data.startTimeTo = data.startTimeFrom;

             return Ext.util.JSON.encode(data);
         }


